import pygame.display as pdis
import pygame.image as pi
import pygame.sprite as ps
from res.glo import src
from res.conf import spritespeed


class ZSprite(ps.Sprite):
    def __init__(self):
        super(ZSprite, self).__init__()
        self.screen = pdis.get_surface()
        self.image = pi.load(src['image']['plane'])
        self.rect = self.image.get_rect()
        self.speed = spritespeed
        self.isRunning = True

    def start(self):
        self.isRunning = True

    def stop(self):
        self.isRunning = False

    def move(self, dis):
        if dis == 'up': self.rect.y -= self.speed
        if dis == 'down': self.rect.y += self.speed
        if dis == 'left': self.rect.x -= self.speed
        if dis == 'right': self.rect.x += self.speed

    def _getpos(self):
        return self.rect.topleft

    def _setpos(self, pos):
        self.rect.topleft = pos

    _pos = property(_getpos, _setpos)

    def _getsize(self):
        return self.rect.size

    def _setsize(self, size):
        self.rect.size = size

    _size = property(_getsize, _setsize)
